package initialize

import (
	"fmt"
	"github.com/elastic/go-elasticsearch/v7"
	"travel-app/common/config"
)

var Es *elasticsearch.Client

func Elasticsearch() {

	nas := config.Nas.Elasticsearch

	cfg := elasticsearch.Config{
		Addresses: []string{
			nas.Addr,
		},
		// ...
	}
	Es, err = elasticsearch.NewClient(cfg)
	if err != nil {
		fmt.Println("es连接失败")
		return
	} else {
		fmt.Println("es初始化成功")
	}
}
